package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.Menu;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository // 加和不加没有影响
public interface MenuDao {

    @Select("SELECT * FROM t_menu WHERE id IN (SELECT rm.`menu_id` FROM t_user_role ur, t_role_menu rm, t_user u WHERE ur.`role_id` = rm.`role_id` AND u.`id` = ur.`user_id` AND u.`username` = #{username})")
    List<Menu> findMenuListByUsername(String username);

    Page<Menu> findPage(String queryString);

    void add(Menu menu);

    void delete(Integer id);

    Menu findById(Integer id);

    void updateMenu(Menu menu);

    List<Menu> findAll();
}
